home *** CD-ROM | disk | FTP | other *** search
- ASTcl 1.0 README file
- Written on 960927.
-
- Copyright (c) 1996 by Theodore C. Belding
- University of Michigan Program for the Study of Complex Systems
- <mailto:Ted.Belding@umich.edu>
- <http://www-personal.engin.umich.edu>
-
- INTRODUCTION
-
- AS Tcl is a freeware package for compiling and running AppleScript
- scripts from within a Mac Tcl or Tk shell. The package adds a single
- command:
-
- DoAppleScript <script>
-
- This command returns the result of the script, or an error message if
- an error occurs.
-
- INSTALLATION
-
- To use this package, include the files ASTcl.c and ASTclUtils.c in your
- project. Then modify your tkMacAppInit.c or tclMacAppInit.c file by including
- "ASTcl.h" and adding the following code to your Tcl_AppInit() function:
-
- if (ASTcl_Init(interp)==TCL_ERROR) {
- return TCL_ERROR;
- }
-
- I've included the sources and project files for PPC, 68K, shared lib-PPC, and fat
- versions of the AS Tcl shell and AS Wish applications, respectively.
- To make the applications, you need:
- - AppleScript installed on your Mac
- - CodeWarrior 10
- - The Tcl 7.5.1 and Tk 4.1 sources from the CodeWarrior 10 Tools CD ROM
- - The compiled libraries from those Tcl sources
-
- You will have to alter the access paths in the projects to match your
- installation.
-
- EXAMPLE
-
- Here's an example of how to run a script within the AS Tcl shell or Wish.
- The AppleScript script returns the name of the frontmost window in the
- Finder. (This script requires the scriptable Finder.) In this case, the
- frontmost window in the Finder was named "ASTcl" when the script was run.
-
- % set script "tell application \"Finder\"\rname of front window\rend tell"
- tell application "Finder"
- name of front window
- end tell
- % set result [DoAppleScript $script]
- ASTcl
- %
-
- Note that you need to insert backslashes "\" before any quotes in the script,
- and separate the lines of the script with "\r" return characters, as shown in
- the example.
-
- NOTES
-
- This package has been tested somewhat on a PowerMac 7100/66 running
- System 7.5.5. It has not been tested extensively, nor has it been tested
- on other Mac setups. Please let me know if you find any problems!
-
- When you issue a DoAppleScript command, the AppleScript script must be
- compiled before it is executed. This compilation takes some time.
-
- Note that the AppleScript script is compiled every time it is executed,
- regardless of whether it's already been compiled in the past. There is
- currently no caching of the compiled script for future use. This is an
- obvious place for improvement.
-
- The maximum length of the result string returned by the AppleScript
- script is defined by kMaxResultLen in ASTcl.c. This value is currently
- 256 characters. Any result longer than this will be truncated.
-
- The basic techniques used to compile and execute an AppleScript script
- in this package should work for any OSA scripting language. All you need
- to do is change the OSAScriptInit() routine in ASTclUtils.c to
- initialize that OSA scripting component instead of AppleScript.
-
- ACKNOWLEDGEMENTS
-
- Thanks to Ray Johnson and the Sun Tcl team for porting Tcl/Tk to the Mac!
-
- This package was inspired by the DoAppleScript command in Matthias Neeracher's
- MacPerl, and by the work of Mark Roseman, Vince Darley, and others on
- Tcl extensions for the Mac. The OSA utilities code was taken from Dave
- Mark's great Ultimate Mac Programming book.